#ifndef __TRKDRV_H
#define __TRKDRV_H

#define EZUSB_TRK_VID 0x546
#define EZUSB_TRK_PID 0x8977

#define NOISE_REDUCTION_A
#define TRKDRV_N_KEYS 16

#ifdef __cplusplus
#define EXTERN_TYPE extern "C"
#else
#define EXTERN_TYPE extern
#endif

#include "qtrack.h"

typedef struct {
	unsigned char sensor_calibration[3];
} trkdrv_params;

// trkdrv_init():
// one may have calibration data for more nodes than are actually used. thus,
// n_nodes and node_calib_data are specified separately

EXTERN_TYPE int trkdrv_init(void);
EXTERN_TYPE int trkdrv_sample(void);
EXTERN_TYPE int trkdrv_sample_ex(void);
EXTERN_TYPE int trkdrv_sample_flat16(void);
EXTERN_TYPE int trkdrv_sample_v10(void);
EXTERN_TYPE int trkdrv_sample_multi16(void);
EXTERN_TYPE void trkdrv_set_parameters(qtrk_node *node_array_arg,int n_nodes_arg);
EXTERN_TYPE void trkdrv_set_calib_test(unsigned char *);
EXTERN_TYPE void trkdrv_allocate_nodes(int);
EXTERN_TYPE void trkdrv_allocate_time_weigh_nodes(int);
EXTERN_TYPE void trkdrv_tactile_feedback(int);
EXTERN_TYPE void trkdrv_time_weigh(void);


//EXTERN_TYPE void trkdrv_set_variable(unsigned char, unsigned char);

EXTERN_TYPE FP trkdrv_calib_global;
EXTERN_TYPE FP trkdrv_calib_const[3];

EXTERN_TYPE int trkdrv_n_nodes;
EXTERN_TYPE qtrk_node *trkdrv_node_array;
EXTERN_TYPE int trkdrv_key_array[TRKDRV_N_KEYS];

// jfh TODO use some bool type here
EXTERN_TYPE unsigned int ezusb_trk_online;

EXTERN_TYPE unsigned char n_cycle_integration;
EXTERN_TYPE unsigned char tim_mod_h;
EXTERN_TYPE unsigned char tim_mod_l;
EXTERN_TYPE unsigned char ph1_h;
EXTERN_TYPE unsigned char ph1_l;

#define	N_NODES_VAR						0
#define N_CYCLE_INTEGRATION_VAR			1
// TIM_MOD_H could be 0, no need to touch
#define TIM_MOD_H_VAR					2
#define TIM_MOD_L_VAR					3

#define PH1_H_VAR						4
#define PH1_L_VAR						5
//EXTERN_TYPE void happystrkdrv_set_var(unsigned char var, unsigned char value);
EXTERN_TYPE void trkdrv_set_variable(unsigned char var, unsigned char value);
#endif // __TRKDRV_H